home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power Programmierung
/
Power-Programmierung (Tewi)(1994).iso
/
magazine
/
drdobbs
/
c_spec
/
sources
/
isdir.c
< prev
next >
Wrap
C/C++ Source or Header
|
1986-02-20
|
669b
|
32 lines
#include <types.h>
#include <stat.h>
isdir( file )
char *file;
{
/* Return true if file exists and is a directory, false
* otherwise. If stat returns non-existant then a disk
* id if any is stripped off. If the resultant file name
* is null, . , .. or / then the root directory is
* intended and 1 is returned.
*/
struct stat buf;
if( !stat( file, &buf) )
{
if( buf.st_mode & S_IFDIR )
return 1;
}
else
{
if( file[0] && file[1] == ':' )
file += 2;
return( ! file[0]
|| file[0] == '.' && !file[1]
|| file[0] == '/' && !file[1]
|| file[0] == '.' && file[1]=='.' && !file[2] );
}
}